Add simple swap data filter.
authoroliskoli <oliskoli>
Mon, 27 Oct 2008 20:44:06 +0000 (20:44 +0000)
committeroliskoli <oliskoli>
Mon, 27 Oct 2008 20:44:06 +0000 (20:44 +0000)
Makefile.in
filter_vecs.c
swapdata.c [new file with mode: 0644]

index 071c13f330c9c7b8e5fb78b849eeb3d851aa5c80..5bf16d6d5bcf537c3ef8f7cd574bbba6984c86f8 100644 (file)
@@ -67,7 +67,7 @@ FMTS=@FMTS@
 
 FILTERS=position.o radius.o duplicate.o arcdist.o polygon.o smplrout.o \
        reverse_route.o sort.o stackfilter.o trackfilter.o discard.o \
-       nukedata.o interpolate.o transform.o height.o
+       nukedata.o interpolate.o transform.o height.o swapdata.o
 
 JEEPS=jeeps/gpsapp.o jeeps/gpscom.o \
        jeeps/gpsmath.o jeeps/gpsmem.o  \
@@ -770,6 +770,8 @@ stmsdf.o: stmsdf.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \
 stmwpp.o: stmwpp.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \
   zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h session.h csv_util.h
 strptime.o: strptime.c strptime.h
+swapdata.o: swapdata.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \
+  zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h session.h filterdefs.h
 tef_xml.o: tef_xml.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \
   zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h session.h xmlgeneric.h
 text.o: text.c defs.h config.h queue.h gbtypes.h zlib/zlib.h zlib/zconf.h \
index 43ed5bac12a4b124fa31f715fc64662cca648bfe..249698346d7045881928bb7db5903d2e301ba739 100644 (file)
@@ -45,6 +45,7 @@ extern filter_vecs_t nuke_vecs;
 extern filter_vecs_t interpolatefilt_vecs;
 extern filter_vecs_t transform_vecs;
 extern filter_vecs_t height_vecs;
+extern filter_vecs_t swapdata_vecs;
 
 static
 fl_vecs_t filter_vec_list[] = {
@@ -124,6 +125,11 @@ fl_vecs_t filter_vec_list[] = {
                "height",
                "Manipulate altitudes"
        },
+       {
+               &swapdata_vecs,
+               "swap",
+               "Swap latitude and longitude of all loaded points"
+       },
        
 #endif
         {
diff --git a/swapdata.c b/swapdata.c
new file mode 100644 (file)
index 0000000..ddbc55e
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+
+    Swap data filter
+
+    Copyright (C) 2008 Olaf Klein, o.b.klein@gpsbabel.org
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
+
+ */
+#include "defs.h"
+#include "filterdefs.h"
+#include <ctype.h>
+
+#define MYNAME "swapdata"
+
+#if FILTERS_ENABLED
+
+static
+arglist_t swapdata_args[] = {
+       ARG_TERMINATOR
+};
+
+static void
+swapdata_cb(const waypoint *ref)
+{
+       waypoint *wpt = (waypoint *)ref;
+       double x;
+
+       x = wpt->latitude;
+       wpt->latitude = wpt->longitude;
+       wpt->longitude = x;
+
+       return;
+}
+
+/*******************************************************************************
+* %%%        global callbacks called by gpsbabel main process              %%% *
+*******************************************************************************/
+
+static void 
+swapdata_process(void) /* this procedure must be present in vecs */
+{
+       waypt_disp_all(swapdata_cb);
+       route_disp_all(NULL, NULL, swapdata_cb);
+       track_disp_all(NULL, NULL, swapdata_cb);
+}
+
+/*******************************************************************************/
+
+filter_vecs_t swapdata_vecs = {
+       NULL,
+       swapdata_process,
+       NULL,
+       NULL,
+       swapdata_args
+};
+
+/*******************************************************************************/
+#endif // FILTERS_ENABLED